package cn.com.thingo.shyintelligent.presenter;

import javax.inject.Inject;

import cn.com.thingo.shyintelligent.base.RxPresenter;
import cn.com.thingo.shyintelligent.base.contract.ForgetPasswordContract;
import cn.com.thingo.shyintelligent.model.DataManager;
import cn.com.thingo.shyintelligent.model.bean.CommonBean;
import cn.com.thingo.shyintelligent.util.LogUtil;
import cn.com.thingo.shyintelligent.util.RxUtil;
import cn.com.thingo.shyintelligent.util.ToastUtil;
import io.reactivex.functions.Consumer;

public class ForgetPasswordPresenter extends RxPresenter<ForgetPasswordContract.View> implements ForgetPasswordContract.Presenter {

    private DataManager dataManager;

    @Inject
    public ForgetPasswordPresenter(DataManager dataManager) {
        this.dataManager = dataManager;
    }


    @Override
    public void sendCode(String telephone) {
//        addSubscribe(dataManager.sendCode(telephone)
//                .compose(RxUtil.<CommonBean>rxSchedulerHelper())
//                .subscribe(new Consumer<CommonBean>() {
//                    @Override
//                    public void accept(CommonBean commonBean) throws Exception {
//                        if (commonBean.getCode() == 0) {
//                            mView.viewGetCode(commonBean);
//                        } else {
//                            ToastUtil.shortShow(commonBean.getMsg());
//                        }
//                    }
//                }, new Consumer<Throwable>() {
//                    @Override
//                    public void accept(Throwable throwable) throws Exception {
//                        LogUtil.e(throwable.getMessage());
//                    }
//                }));
    }

    @Override
    public void modifyPassword(String password, String telephone, String code) {
//        addSubscribe(dataManager.modifyPassword(password, telephone, code)
//                .compose(RxUtil.<CommonBean>rxSchedulerHelper())
//                .subscribe(new Consumer<CommonBean>() {
//                    @Override
//                    public void accept(CommonBean commonBean) throws Exception {
//                        if (commonBean.getCode() == 0) {
//                            mView.viewModifyPassword(commonBean);
//                        } else {
//                            ToastUtil.shortShow(commonBean.getMsg());
//                        }
//                    }
//                }, new Consumer<Throwable>() {
//                    @Override
//                    public void accept(Throwable throwable) throws Exception {
//                        LogUtil.d(throwable.getMessage());
//                    }
//                }));
    }
}
